/*
 * TestWarteschlange.java
 * 
 *  author: Daniel Rudigier
 *    date: 22.05.2008
 * 
 * 
 */
package ocumed.applikation.tests;

import java.util.List;

import junit.framework.TestCase;
import ocumed.persistenz.dao.BenutzerDAO;
import ocumed.persistenz.dao.DAOFactory;
import ocumed.persistenz.dao.PatientDAO;
import ocumed.persistenz.dao.TerminDAO;
import ocumed.persistenz.dao.WartepositionDAO;
import ocumed.persistenz.hibernate.OcPatient;
import ocumed.persistenz.hibernate.OcWarteposition;
import ocumed.teams.teamb.application.PatientReihung;

/**
 * @author Daniel Rudigier
 *
 */
public class TestWarteschlange extends TestCase {
    private PatientDAO pDAO = DAOFactory.get(DAOFactory.RDBMS).getPatientDAO();
    private WartepositionDAO wDAO = DAOFactory.get(DAOFactory.RDBMS).getWartepositionDAO();
    
    /**
     * add some guys
     */
    public void testEinreihen() {
        PatientReihung pr = new PatientReihung();
        
        int a = 1;
        for(short i = 1; i <= 20; i++) {
            try {
                pr.einreihen(i, a);
            } catch (Exception e) { /* don't care, let's go! */ }
            if (i > 10) {
                a++;
            }
        }
    }
    
    /**
     * get a queue for a specific doctor
     */
    public void testListe() {        
        int arztId = 3;
        PatientReihung pr = new PatientReihung();
        List<Integer> toGui = pr.getWarteschlange(arztId);
        
        System.out.println("queue for: (" + arztId + ") " + pr.getArztName(arztId));
        for(Integer id : toGui) {
            System.out.println(id + ": " + pr.getPatient(id));
        }
    }
    
    /**
     * test unique constraint
     */
    public void testUniqueness() {
        PatientReihung pr = new PatientReihung();
        try {
            pr.einreihen(1,1);
        } catch (Exception e) {
            // should be thrown
            assertEquals(true, true);
        }
    }
    
    /**
     * test up, down
     */
    public void testReihung() {
        PatientReihung pr = new PatientReihung();
        pr.hoch(5);
    }
    
    /**
     * delete it
     */
    public void testAusreihen() {
        PatientReihung pr = new PatientReihung();
        pr.ausreihen(5);
    }

}
